﻿Public Class FrmMain
    Dim SettingsPath As String = Application.StartupPath
    Dim Profile1Path As String = String.Empty
    Dim Profile2Path As String = String.Empty
    Dim ErrorLog As String = String.Empty
    Dim FilesMissing As Integer = 0
    Dim PathsMissing As Integer = 0

    Private Sub FrmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        If My.Computer.FileSystem.FileExists(SettingsPath & "\settings.txt") = True Then
            ErrorLog = SavingClass.LoadSettings(SettingsPath)
            If Not ErrorLog = "OK" Then
                MsgBox("Error loading settings: " & ErrorLog, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Title:="Error")
                ErrorLog = String.Empty
            End If
        Else
            If MsgBox("No settings found, do you want to set them now?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, Title:="Question") = MsgBoxResult.Yes Then
                FrmSettings.Show()
                Me.Hide()
            End If
        End If
        If My.Settings.ProfileSelected = 1 Then
            RadioProfile1.Checked = True
        ElseIf My.Settings.ProfileSelected = 2 Then
            RadioProfile2.Checked = True
        End If
    End Sub

    Private Sub BtnOpen_Click(sender As Object, e As EventArgs) Handles BtnOpen.Click
        If My.Settings.ProfileSelected = 0 Then
            MsgBox("Please select a profile", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Title:="Error")
        Else
            FrmYouTube.Show()
            Me.Hide()
        End If
    End Sub

    Private Sub RadioProfile1_CheckedChanged(sender As Object, e As EventArgs) Handles RadioProfile1.CheckedChanged
        If RadioProfile1.Checked = True Then
            My.Settings.ProfileSelected = 1
            ErrorLog = SavingClass.SaveSettings(SettingsPath)
            If Not ErrorLog = "OK" Then
                MsgBox("Error loading settings: " & ErrorLog, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Title:="Error")
                ErrorLog = String.Empty
            End If
        End If
    End Sub

    Private Sub RadioProfile2_CheckedChanged(sender As Object, e As EventArgs) Handles RadioProfile2.CheckedChanged
        If RadioProfile2.Checked = True Then
            My.Settings.ProfileSelected = 2
            ErrorLog = SavingClass.SaveSettings(SettingsPath)
            If Not ErrorLog = "OK" Then
                MsgBox("Error loading settings: " & ErrorLog, MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Title:="Error")
                ErrorLog = String.Empty
            End If
        End If
    End Sub

    Private Sub BtnCheckFiles_Click(sender As Object, e As EventArgs) Handles BtnCheckFiles.Click
        Profile1Path = My.Settings.Profile1Path & "\"
        Profile2Path = My.Settings.Profile2Path & "\"
        If Profile1Path = String.Empty Then
            PathsMissing += 1
        End If
        If Profile2Path = String.Empty Then
            PathsMissing += 1
        End If
        If PathsMissing = 0 Then
            If My.Computer.FileSystem.FileExists(Profile1Path & "firefox05.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "hotmail01.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "hotmail02.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "hotmail04.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "hotmailclosetab.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "hotmailrefresh.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "u2bviews06.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "u2bviews07.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "u2bviews08.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "u2bviews14.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "u2bviewsuser.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "upload01.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "upload02.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "youtube03.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytback.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytclosetab.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytfirstok.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytlink.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytlink2.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytnext.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytnext2.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytnextstep.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytprocdone.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytsettingspublic.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytsettingssave.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytuploaddone.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytverify.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytverifyemail.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile1Path & "ytverifylink.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "firefox05.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "hotmail01.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "hotmail02.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "hotmail04.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "hotmailclosetab.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "hotmailrefresh.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "u2bviews06.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "u2bviews07.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "u2bviews08.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "u2bviews14.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "u2bviewsuser.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "upload01.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "upload02.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "youtube03.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytback.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytclosetab.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytfirstok.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytlink.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytlink2.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytnext.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytnext2.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytnextstep.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytprocdone.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytsettingspublic.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytsettingssave.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytuploaddone.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytverify.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytverifyemail.bmp") = False Then
                FilesMissing += 1
            End If
            If My.Computer.FileSystem.FileExists(Profile2Path & "ytverifylink.bmp") = False Then
                FilesMissing += 1
            End If
        Else
            MsgBox("There are paths missing, please set them first", MsgBoxStyle.Exclamation + MsgBoxStyle.OkOnly, Title:="Error")
            PathsMissing = 0
        End If
        If FilesMissing > 0 Then
            MsgBox("There are " & FilesMissing & " files missing", MsgBoxStyle.Critical + MsgBoxStyle.OkOnly, Title:="Info")
            FilesMissing = 0
        Else
            MsgBox("No files are missing", MsgBoxStyle.Information + MsgBoxStyle.OkOnly, Title:="Info")
        End If
    End Sub

    Private Sub BtnSettings_Click(sender As Object, e As EventArgs) Handles BtnSettings.Click
        FrmSettings.Show()
        Me.Hide()
    End Sub

    Private Sub BtnMinimize_Click(sender As Object, e As EventArgs) Handles BtnMinimize.Click
        Me.WindowState = FormWindowState.Minimized
    End Sub

    Private Sub TimerHide_Tick(sender As Object, e As EventArgs) Handles TimerHide.Tick
        If FrmSettings.Visible = True Then
            Me.Hide()
        End If
    End Sub

    Private Sub BtnInfo_Click(sender As Object, e As EventArgs) Handles BtnInfo.Click
        FrmInfo.Show()
        Me.Hide()
    End Sub
End Class